﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class membership_index : MemberPageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        PageBegin();

        if (!IsPostBack)
        {
            Init();
            LoadingProductList();
        }
    }

    void Init()
    {
        decimal _integral = this.UserInfo.UserIntegral;
        _integral = (_integral < 0) ? 0 : _integral;
        lblIntegral.Text = _integral.ToString();

        lblIntegralTotal.Text = BLL.CommonBLL.ExecuteScalar("IntegrationHistory", "ISNULL(SUM(IntegralCount), 0)", " AND " + string.Format(" UserId='{0}'",this.UserId)).ToString();
        lblOrderTotal.Text = BLL.CommonBLL.ExecuteScalar("OrderBase", "ISNULL(COUNT(1), 0)", " AND " + string.Format(" UserId='{0}'", this.UserId) + " AND StatusCode = 0").ToString();
    }

    void LoadingProductList()
    {
        DataTable dat = BLL.CommonBLL.Select("vw_ProductBase", "TOP 4 *", " AND DeletionStateCode = 0 AND ProductTypeCode = 1 ORDER BY ProductNumber ASC");
        rptProductList.DataSource = dat;
        rptProductList.DataBind();
    }
}